<?php
/**
 * Created on 29-mag-2006
 * jaco_at_pixeldump
 * button width sound event
 */

include("sample_utils.php");                               // provides some utils and using mk

$swfFN = "buttonSound.swf";                                // swf we'll generate
$sndFN = "ringout.mp3";                                    // sound to insert

$svgFN1 = "inkscape_bt_off.svg";                           // vector data for button state off
$svgFN2 = "inkscape_bt_over.svg";                          // button state over
$svgFN3 = "inkscape_bt_down.svg";                          // state down
$svgFN4 = "inkscape_bt_hit.svg";                           // hit

$svg1 = new MKSimpleSvgReader($svgFN1);                  // build tag data
$svgTD1 = $svg1->update_tagData();                         //

$svg2 = new MKSimpleSvgReader($svgFN2, "", 2);           //
$svgTD2 = $svg2->update_tagData();

$svg3 = new MKSimpleSvgReader($svgFN3, "", 3);           //
$svgTD3 = $svg3->update_tagData();

$svg4 = new MKSimpleSvgReader($svgFN4, "", 4);           //
$svgTD4 = $svg4->update_tagData();

$snd = new MKSoundContainer("", $sndFN, "", 5);           //
$sndTD = $snd->update_tagData();

$shapeAr = array($svg4, $svg3, $svg2, $svg1);              // prepare for button
$button = new MKButtonContainer("", 6);                   // a fresh button
$buttonTD = $button->build_from_array($shapeAr);           // build states
$button->set_sound_event(5, ROLL_OVER);                    // a sound event
$buttonSoundTD = $button->update_buttonSound_tagData();    // get sound event tag data

$button->move(35, 15);                                     // place @35,15
$buttonTD = $button->build_from_array($shapeAr);           // use shape array for placing an setting states
$buttonPB = $button->update_place_tagData();               // place tag data

$swf = new MKSwf($swfFN);                                  // a fresh swf
$swf->set_stage_dimensions(200, 100);                      // width/height 200/100
$swf->set_backgroundColor("#33CC33");                      // a kind of green as background color
$swf->set_swfDir(SERVER_MKTMP);                            // set output directory

$swf->add_tagData($svgTD1);                                // start to populate
$swf->add_tagData($svgTD2);                                //
$swf->add_tagData($svgTD3);                                //
$swf->add_tagData($svgTD4);                                //

$swf->add_tagData($sndTD);                                 // sound tag data

$swf->add_tagData($buttonTD);                              // button tag data
$swf->add_tagData($buttonSoundTD);                         // button sound event tag data
$swf->add_tagData($buttonPB);                              // place button on stage
$swf->swf_output();                                        // save

$swfHeader = $swf->fetch_assoc();                          // prepare to publish

$str = render_swf_box($swfHeader, $imgDir, false);
$str .= "<br/><strong>" .$swfFN ." created in :<br />" .SERVER_MKTMP ."</strong>";
echo show_content($str, basename(__FILE__));
?>
